<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/js/jquery.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/global.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/index.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/Font-Awesome-3.2.1/css/font-awesome.min.css");
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/alert.js",CClientScript::POS_HEAD);

Yii::app()->clientScript->registerCss("CSS1","
    .cont_box img{
        height: 200px;
    }

   #loadings {
        left: 50%;
        position: absolute;
        top: 50%;
    }

");


?>
<style type="text/css">
    .main-box {

        height: 100%;
        left: 0;
        margin: 0 auto;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: -1;
    }
    .morcon {
        height: 100px;
        margin: 245px 20px 20px;
        position: relative;
        text-align: center;
    }

    .morcon .reg {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        font-size: 20px;
        left: 4%;
        position: absolute;
        top: 0;
    }
    .morcon .login {
        background: rgba(255, 255, 255, 0) none repeat scroll 0 0;
        border: medium none;
        color: #fff;
        display: block;
        font-size: 20px;
        left: 51%;
        position: absolute;
        top: 39%;
    }

    .wrap .header{
        width: 100%;
        position: relative;
        height: 300px;
    }
    .wrap .footer {
        height: 300px;
        position: relative;
        width: 100%;
    }

    .wrap .header .mydodo{
         background: url("<?php echo $this->staticsPath."/img/mydodo.png" ?>") no-repeat scroll 0 0 / 150px auto;
         height: 40px;
         width: 150px;
         position: absolute;
         right: 15px;
         top: 25px;
     }
    .wrap .header .imgbg{
        background: url("<?php echo $this->staticsPath."/img/imgbg.png" ?>") no-repeat scroll 0 0 / 150px auto;
        height: 150px;
        width: 150px;
        position: absolute;
        left: 15px;
        top: 90px;
    }
    .imgbg .box{
        width: 100%;
        height: 100%;
        position: relative;
    }
    .imgbg .box img {
        border-radius: 50%;
        height: 80%;
        left: 15px;
        position: absolute;
        top: 15px;
        width: 80%;
    }
    .wrap .header .hname {
        height: 200px;
        left: 170px;
        position: absolute;
        top: 144px;
        width: 200px;
    }
    .wrap .header .hname p{
        color: #0066b3;
        font-size: 20px;
    }
    .wrap .header .list {


        height: 80px;
        left: 25px;
        position: absolute;
        top: 25px;
        width: 80px;
    }
    .wrap .header .list a{
        color: #0066b3;
        font-size: 30px;
    }
    .wrap .footer .fbotton{
        width: 33%;
        height: 150px;
        float: left;
    }
    .wrap .footer .fbotton .like{
        background: url("<?php echo $this->staticsPath."/img/mylike.png" ?>") no-repeat scroll 13px 0 / 90px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .collection{
        background: url("<?php echo $this->staticsPath."/img/mycollection.png" ?>") no-repeat scroll 13px 0 / 104px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .share{
        background: url("<?php echo $this->staticsPath."/img/share.png" ?>") no-repeat scroll -2px 15px / 114px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .point{
        background: url("<?php echo $this->staticsPath."/img/point.png" ?>") no-repeat scroll 6px 0 / 104px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .pointlist{
        background: url("<?php echo $this->staticsPath."/img/pointlist.png" ?>") no-repeat scroll 13px 0 / 90px auto;
        height: 100%;
        width: 100%;
    }
    .wrap .footer .fbotton .pointgift{
        background: url("<?php echo $this->staticsPath."/img/pointgift.png" ?>") no-repeat scroll 13px 11px / 90px auto;
        height: 100%;
        width: 100%;
    }

    body{
        background: #f4f4f4 none repeat scroll 0 0;
    }
    .topban{
        padding: 0 10px
    }
    .topban .top {
        color: #888;
        height: 20px;
        left: 50%;
        line-height: 20px;
        margin: -10px 0 52px -30px;
        position: absolute;
        top: 50%;
    }
    #logout{
        color: #ffffff;
        font-size: 18px;
    }
    #logout:hover{
        color: #ffffff;
    }
    .lgt{

        width: 90%;
        height: 50px;
        text-align: center;
        margin: 20px auto 0 auto;
        margin-bottom: 50px;
        background: rgb(231,66,60);
        border-radius: 8px;
        line-height: 50px;
    }
    .right {
        float: right;
        margin-top: 20px;
    }
    .wrap .fa{
        width: 36px;
    }
    section a {
        color:#999
    }
    .modl_tel {
        background: #ffffff none repeat scroll 0 0;
        border-bottom: 1px solid #ccc;
        height: 60px;
        line-height: 60px;
        margin: 10px 0;
        padding-left: 10px;
    }
    .topban {
        padding: 0 10px;
    }
    .topban {
     	background: #fff none repeat scroll 0 0;
        height: 140px;
        overflow: unset;
        position: relative;
        width: 100%;
    }
    .status-people-pic {
        left: 0;
        margin-left: 15px;
        margin-top: -50px;
        position: absolute;
        top: 50%;
    }
    .stat-people {
        background: #fafafa none repeat scroll 0 0;
        border-radius: 30em;
        display: block;
        padding: 7px;
        position: relative;
        width: 100px;
    }
    .topban {
        overflow: unset;
        position: relative;
        width: 100%;
    }
    .nav {
        background: rgb(249, 249, 249) none repeat scroll 0 0;
        border-top: 1px solid #ddd;
        bottom: 0;
        opacity: 0.9;
        padding: 6px 0 !important;
        position: fixed;
        width: 100%;
        height: 55px;
    }
    .nav .nav-box {
        color: #333;
        float: left;
        font-size: 14px;
        text-align: center;
        width: 33%;
        height: 100%;
    }
    .nav .nav-box.actt{
        color: #068043;
    }
</style>
<?php if($status=='no'){ ?>
    <div  class="loading" style="display: block">
        <div id="loading">
            <div id="loadings">
                <i class="fa fa-cog fa-spin"></i>
            </div>
        </div>
    </div>
<?php } ?>
<div class="data"  <?php if($status=='no'){ ?>style="display: none"<?php } ?>>
    <section class="wrap">
        <div class="topban pdX10">
            <div class="status-people-pic">
                <?php if($user_info->sex==1){ ?>
                    <img class="stat-people" src="<?php echo $this->staticsPath."/img/tx6.jpg" ?>" />
                <?php }else{ ?>
                    <img class="stat-people" src="<?php echo $this->staticsPath."/img/tx5.jpg" ?>" />
                <?php } ?>

            </div>
            <div class="top name"><span><?php echo $child_info->user_name.'的'.$user_info->is_relation; ?></span></div>
        </div>
        <section class="cont_wrpa">
<!--            <a id="switch"  href="javascript:void(0);">-->
<!--                <div class="modl_tel">-->
<!--                    <i class="fa fa-repeat" style="color:#068043;"></i>切换学生账号-->
<!--                    <i class="fa fa-chevron-right right"></i>-->
<!--                </div>-->
<!--            </a>-->

            <a href="<?php echo Yii::app()->createUrl('user/hot',array('openid'=>$openid)) ?>">
                <div class="modl_tel">
                    <i class="fa fa-fire" style="color:#068043;"></i>热门书籍
                    <i class="fa fa-chevron-right right"></i>
                </div>
            </a>

            <a href="<?php echo Yii::app()->createUrl('user/myPointlist1',array('openid'=>$openid)) ?>">
                <div class="modl_tel">
                    <i class="fa fa-dollar" style="color:#068043;"></i>积分统计
                    <i class="fa fa-chevron-right right"></i>
                </div>
            </a>
            <a href="<?php echo Yii::app()->createUrl('user/read',array('openid'=>$openid)) ?>">
                <div class="modl_tel">
                    <i class="fa fa-star-o" style="color:#068043;"></i>阅读统计
                    <i class="fa fa-chevron-right right"></i>
                </div>
            </a>
            <a href="<?php echo Yii::app()->createUrl('user/like',array('openid'=>$openid)) ?>">
                <div class="modl_tel">
                    <i class="fa fa-table" style="color:#068043;"></i>最喜爱的书籍
                    <i class="fa fa-chevron-right right"></i>
                </div>
            </a>
            <a id="logout" href="javascript:void(0);"><div class="lgt">退出登录</div></a>
        </section>
    </section>





    <nav class="nav">
        <a href="<?php echo Yii::app()->createUrl('index/list1',array('openid'=>$openid)) ?>" class="">
            <div class="nav-box">
                <i class="fa fa-book"></i>书目
            </div>
        </a>
        <?php if($user_info->role==2){ ?>
            <a href="<?php  echo Yii::app()->createUrl('user/child',array('openid'=>$openid)); ?>" class="">
                <div class="nav-box">
                    <i class="fa fa-user"></i>我的孩子
                </div>
            </a>
        <?php }else{ ?>
            <a href="<?php  echo Yii::app()->createUrl('user/student',array('openid'=>$openid)); ?>" class="">
                <div class="nav-box">
                    <i class="fa fa-users"></i>我的学生
                </div>
            </a>
        <?php } ?>
        <a href="<?php echo Yii::app()->createUrl('user/index',array('openid'=>$openid)); ?>" class="">
            <div class="nav-box actt">
                <i class="fa fa-home"></i>个人中心
            </div>
        </a>
    </nav>
</div>

<script type="text/javascript">

    <?php if($status=='no'){ ?>
    $(function(){
        var storage = window.localStorage;
        var stroeUser = storage["stroeUser"];
        $.ajax({
            type: "POST",
            url: '<?php echo Yii::app()->createUrl('user/ajaxCheckUser'); ?>',
            data: {
                stroeUser:stroeUser
            },
            dataType: "json",
            success: function (data) {
                if (data) {
                    if(data.status==1){
                        window.location.reload();
                    }else{
                        window.location.href='<?php echo Yii::app()->createUrl('index/login',array('openid'=>$openid)); ?>';
                    }
                }else{
                    window.location.href='<?php echo Yii::app()->createUrl('index/login',array('openid'=>$openid)); ?>';
                }
            }
        });

    });
    <?php } ?>
    $(function(){
        $("#switch").click(function(){
            if(window.confirm('你确定要切换成学生账号吗？')){
            $.ajax({
                type: "POST",
                url: '<?php echo Yii::app()->createUrl('index/ajaxSwitch'); ?>',
                dataType: "json",
                data: {
                    openid:'<?php echo $openid; ?>'
                },
                success: function (data) {
                    if (data) {
                        if(data.status==1){
                            window.localStorage["stroeUser"] = data.key;
                            window.location.reload();
                        }else{
                            alert('切换失败');
                        }
                    }else{
                        alert('切换失败');
                    }
                }
            });
            }
        });
        $("#logout").click(function(){
            if(window.confirm('你确定要退出账号吗？')){
                $.ajax({
                    type: "POST",
                    url: '<?php echo Yii::app()->createUrl('index/ajaxLogout'); ?>',
                    dataType: "json",
                    success: function (data) {
                        if (data) {
                            if(data.status==1){
                                window.localStorage["stroeUser"] = '';
                                window.location.href=data.url;
                            }else{
                                alert('退出失败');
                            }
                        }else{
                            alert('退出失败');
                        }
                    }
                });
            }
        });
    });
</script>